package 数组查找.二分法查找.test01;

public class ArraySearch {
    public static void main(String[] args) {
        int[] arr = {4,5,8,2,89};
        /*
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == 89){
                System.out.println("89元素的下标是：" + i);
                return;
            }
        }
        */
        arraySearch(arr,2);
    }
    public static void arraySearch(int[] arr,int ele){
        for (int i = 0; i < arr.length; i++) {
            if(ele == arr[i]){
                System.out.println(ele + "下标是：" + i);
                return;
            }
        }
        System.out.println(ele + "不存在该数组");
        return;
    }
}
